package com.dgut.dao;

import com.dgut.pojo.Record;
import com.dgut.pojo.RecordRelationPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface RecordDao extends JpaRepository<Record,RecordRelationPK> {
    List<Record> findAllById(Long id);
    @Query(value = "SELECT * FROM springboot.record where to_days(time) = to_days(now()) and id = ?1 ",nativeQuery = true)
    Record findTodayRecordById(Long id);
    @Query(value = "SELECT * FROM springboot.record where to_days(time) = to_days(now())-1 and id = ?1 ",nativeQuery = true)
    Record findLastDayRecordById(Long id);
    @Query(value = "SELECT * FROM springboot.record where id = ?1 order by time desc limit 1",nativeQuery = true)
    Record findNewestRecordById(Long id);

}
